package com.ruibang.glass.equipment.controller;


import com.ruibang.glass.equipment.constant.Constants;
import com.ruibang.glass.equipment.domain.req.device.CraneReq;
import com.ruibang.glass.equipment.entity.device.Crane;
import com.ruibang.glass.equipment.service.CraneService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
 * <p>
 *起重设备服务
 * </p>
 *
 * @author mameng
 * @since 2024-03-20
 */
@RestController
@RequestMapping("/api/equipment/crane")
@Api(value = "起重设备")
public class CraneController {
    @Autowired
    private CraneService craneService;

    @PostMapping("list")
    @ApiOperation(value = "起重设备列表", response = ResultBody.class)
    public ResultBody getBoilerList(@RequestBody CraneReq craneReq) {
        return ResultBody.success(craneService.queryPage(craneReq));
    }

    @PostMapping("/deleteById")
    @ApiOperation(value = "删除实体", response = ResultBody.class)
    public ResultBody deleteById(@RequestBody Crane crane) {
        craneService.lambdaUpdate().eq(Crane::getId,crane.getId()).set(Crane::getIsDelete,Constants.ONE_STR).update();
        return ResultBody.success();
    }

    @PostMapping("/getPressureVesselById")
    @ApiOperation(value = "获取对象", response = ResultBody.class)
    public ResultBody getBoilerInfoById(@RequestBody Crane crane) {
        Crane byId = craneService.getById(crane.getId());
        return ResultBody.success(byId);
    }

    @PostMapping("/updateBoilerInfo")
    @ApiOperation(value = "更新", response = ResultBody.class)
    public ResultBody updateBoilerInfo(@RequestBody Crane crane) {
        return ResultBody.success(craneService.updateOrAddById(crane));
    }

}
